define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Lookinto,GoDialog) {

		//要传递的参数
		 $scope.act_id = "";
		 $scope.order = new Array();

		 //加载数据
	     $scope.init_data=function(){
	        Lookinto.getlist('act_id','member','member_id',function(data){
	            $scope.list=data;
	            $scope.act_id = $scope.list.act_id;//活动id
	        });
	    }
	    $scope.init_data();//必须在定义之后

	    //清空数组
	    $scope.clearOrder = function(){
	    	if($scope.order.length>0){
	    		 $scope.order.splice(0,$scope.order.length);
	    	}
	    }

	    //确定接受问卷
	    $scope.agree = function(){
			var checkboxs = document.getElementsByClassName("checkbox_order");
			for (var i=0;i<checkboxs.length;i++) {//获取order_id
				if(checkboxs[i].checked){
						$scope.order.push($scope.list.order[i].order_id);//往数组中增加元素

				}
			}
			if($scope.order.length==0){//判断是否有数据
				GoDialog.toast("请选择中奖人！");
				return ;
			}else{
				 Lookinto.agree($scope.act_id,$scope.order,function(data){
		    	  	if(data.success){
		    	  		GoDialog.toast("提交数据成功！");
		    	  	}else{
		    	  		GoDialog.toast("提交数据失败！");
		    	  	}
		         });
			}

	    }
	    //暂不接受
	    $scope.tui=function(){
	        window.history.go(-1);
	    }


	}



	controller.$inject = ['$scope', 'Lookinto','GoDialog'];

	return app.registerController("lookintoctrl",controller);
});